'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)

	let baseUrl = 'http://aliv18.data.moji.com';
	let apiUrl = baseUrl + '/whapi/json/alicityweather/condition';
	const res = await uniCloud.httpclient.request(apiUrl, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
			'Authorization': 'APPCODE 277ec4ab3a3747dcbd6de6f4687e5fb5'
		},
		data: {
			cityId: event.cityId,
			token: "50b53ff8dd7d9fa320d3d3ca32cf8ed1"
		},
		contentType: 'json', // 指定以application/json发送data内的数据
		dataType: 'json' // 指定返回值为json格式，自动进行parse
	})
	console.log("getWeatherNow res is: ", res);

	//返回数据给客户端
	return res.data;
};